import request from '@/utils/request'
import { Category, CategorySaveOrUpdateParam, CategoryRemoveParam } from '@/types'
import { TreeParam } from '@/types/common-api'

export const tree = (param: TreeParam): Promise<Category[]> => {
  return request({
    url: '/category/tree',
    method: 'post',
    data: param,
  })
}

export const saveOrUpdate = (param: CategorySaveOrUpdateParam): Promise<Category> => {
  return request({
    url: '/category/saveOrUpdate',
    method: 'post',
    data: param,
  })
}

export const remove = (param: CategoryRemoveParam): Promise<unknown> => {
  return request({
    url: '/category/remove',
    method: 'post',
    data: param,
  })
}
